import axios from 'axios'

import nprogress from 'nprogress';
import  'nprogress/nprogress.css';

let myRequest = axios.create({
    baseURL: '/mock',
    timeout: 10000
})

myRequest.interceptors.request.use((config) => {
    nprogress.start();
    return config;
})

myRequest.interceptors.response.use((resp) => {
    nprogress.done();
    return resp.data;
}, (error) => {
    return Promise.reject(new Error('fail'));
});

export default myRequest;